package org.example.Servicelmpl;

import org.example.BusinessExcption;
import org.example.Service.UserService;
import org.example.domain.User;
import org.example.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServicelmpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String username, Integer pass) throws BusinessExcption {
        Integer userpaasword =  userMapper.getPassword(username, pass);
        if (userpaasword == null){
            throw new BusinessExcption("用户不存在");
        }
        if (userpaasword.equals(pass)){
            User user = User.builder().username(username).status(true).build();
            return user;
        }else {
            throw new BusinessExcption("密码错误");
        }
    }
}
